package com.ssm.util;


public class PageSupport {
    //当前页码 来自于用户输入
    private int currentPageNo = 1;
    //总页数 totalCount/pageSize(+1)
    private int totalPageCount = 1;
    //总数量（数据个数）
    private int totalCount = 0;
    //页面容量
    private int pageSize = 4;/*默认页面大小为4*/
    private int offset;/*查询结果偏移量*/

    public void setCurrentPageNo(int currentPageNo) {/*设置当前页面*/
        this.currentPageNo = currentPageNo;
    }

    public int getPageSize() {
        return pageSize;
    }

    public int getTotalPageCount() {/*获取页面总数*/
        if (pageSize>0&&totalCount>pageSize){
            totalPageCount = (totalCount%pageSize==0)?totalCount/pageSize:totalCount/pageSize+1;
        }
        else{
            totalPageCount = 1;
        }
        return totalPageCount;
    }

    public int getCurrentPageNo() {
        return currentPageNo;
    }

    public void setTotalCount(int totalCount) {/*设置记录数*/
        this.totalCount = totalCount;
    }

    public void setPageSize(int pageSize) {/*设置页面大小*/
        this.pageSize = pageSize;
    }

    public int getOffset() {
        offset = (currentPageNo-1)*pageSize;
        return offset;
    }


}
